<?php
class User extends AppModel
{
    var $name = 'User';
    var $belongsTo = 'Role';
    
    function validateLogin($data)
    {
    $user = $this->find(array('username' => $data['username'], 'password' => md5($data['password'])), array('id', 'username','usuario','Role.rol_sistema','Role.sigla'));

    //$user = $this->query("select * from users as t1 inner join roles as t2 on t1.role_id=t2.id where t1.username='".$data['username']."' and t1.password='".md5($data['password'])."'");
    //debug($user);
        if(empty($user) == false)
            return array($user['User'],$user['Role']);
        return false;
    }
    
} 
?>